/* 
 * Copyright (C) 2012 Martin Řehánek <rehan at mzk.cz>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

goog.provide('kramerius.audio.debug_utils');

goog.require('goog.ui.Component');


kramerius.audio.debug_utils.appendDebugListeners = function(control, controlName){
    console.log("Appending debug listeners to the " + controlName );
    if (control == null){
        console.log("WARNING: '" + controlName + "' is null" );
    }
    
    //goog.events.EventType
    console.log("Appending listeners to events from goog.events.EventType");
   
    goog.events.listen(control, goog.events.EventType.SCROLL,
        function (e) {
            console.log(controlName + ": goog.events.EventType.SCROLL");
        });
    
    goog.events.listen(control, goog.events.EventType.LOAD,
        function (e) {
            console.log(controlName + ": goog.events.EventType.LOAD");
        });
        
    goog.events.listen(control, goog.events.EventType.DEACTIVATE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.DEACTIVATE");
        });
        
    goog.events.listen(control, goog.events.EventType.DRAGOVER,
        function (e) {
            console.log(controlName + ": goog.events.EventType.DRAGOVER");
        });
    
    goog.events.listen(control, goog.events.EventType.RESIZE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.RESIZE");
        });
        
    goog.events.listen(control, goog.events.EventType.TOUCHMOVE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.TOUCHMOVE");
        });
        
    goog.events.listen(control, goog.events.EventType.KEYDOWN,
        function (e) {
            console.log(controlName + ": goog.events.EventType.KEYDOWN");
        });
        
//    goog.events.listen(control, goog.events.EventType.ONLINE,
//        function (e) {
//            console.log(controlName + ": goog.events.EventType.ONLINE");
//        });
    
    goog.events.listen(control, goog.events.EventType.INPUT,
        function (e) {
            console.log(controlName + ": goog.events.EventType.INPUT");
        });
        
//    goog.events.listen(control, goog.events.EventType.DBCLICK,
//        function (e) {
//            console.log(controlName + ": goog.events.EventType.DBCLICK");
//        });
        
    goog.events.listen(control, goog.events.EventType.BEFORECUT,
        function (e) {
            console.log(controlName + ": goog.events.EventType.BEFORECUT");
        });
        
    goog.events.listen(control, goog.events.EventType.ERROR,
        function (e) {
            console.log(controlName + ": goog.events.EventType.ERROR");
        });
        
//    goog.events.listen(control, goog.events.EventType.TRANSITIONED,
//        function (e) {
//            console.log(controlName + ": goog.events.EventType.TRANSITIONED");
//        });
        
    goog.events.listen(control, goog.events.EventType.SELECTSTART,
        function (e) {
            console.log(controlName + ": goog.events.EventType.SELECTSTART");
        });
        
    goog.events.listen(control, goog.events.EventType.MOUSEOUT,
        function (e) {
            console.log(controlName + ": goog.events.EventType.MOUSEOUT");
        });
        
//    goog.events.listen(control, goog.events.EventType.BEFOREUNLOAD,
//        function (e) {
//            console.log(controlName + ": goog.events.EventType.BEFOREUNLOAD");
//        });
        
//    goog.events.listen(control, goog.events.EventType.DRAGEND,
//        function (e) {
//            console.log(controlName + ": goog.events.EventType.DRAGEND");
//        });
    
    goog.events.listen(control, goog.events.EventType.FOCUSIN,
        function (e) {
            console.log(controlName + ": goog.events.EventType.FOCUSIN");
        });
        
    goog.events.listen(control, goog.events.EventType.SELECT,
        function (e) {
            console.log(controlName + ": goog.events.EventType.SELECT");
        });
        
    goog.events.listen(control, goog.events.EventType.PROPERTYCHANGE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.PROPERTYCHANGE");
        });
        
    goog.events.listen(control, goog.events.EventType.PAGESHOW,
        function (e) {
            console.log(controlName + ": goog.events.EventType.PAGESHOW");
        });
        
    goog.events.listen(control, goog.events.EventType.PASTE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.PASTE");
        });
        
        
    goog.events.listen(control, goog.events.EventType.BLUR,
        function (e) {
            console.log(controlName + ": goog.events.EventType.BLUR");
        });
        
    goog.events.listen(control, goog.events.EventType.DROP,
        function (e) {
            console.log(controlName + ": goog.events.EventType.DROP");
        });
        
    goog.events.listen(control, goog.events.EventType.SUBMIT,
        function (e) {
            console.log(controlName + ": goog.events.EventType.SUBMIT");
        });
        
    goog.events.listen(control, goog.events.EventType.LOSECAPTURE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.LOSECAPTURE");
        });
        
    goog.events.listen(control, goog.events.EventType.TOUCHEND,
        function (e) {
            console.log(controlName + ": goog.events.EventType.TOUCHEND");
        });
        
    goog.events.listen(control, goog.events.EventType.READYSTATECHANGE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.READYSTATECHANGE");
        });
        
    goog.events.listen(control, goog.events.EventType.HELP,
        function (e) {
            console.log(controlName + ": goog.events.EventType.HELP");
        });
        
    goog.events.listen(control, goog.events.EventType.TOUCHSTART,
        function (e) {
            console.log(controlName + ": goog.events.EventType.TOUCHSTART");
        });
        
    goog.events.listen(control, goog.events.EventType.KEYPRESS,
        function (e) {
            console.log(controlName + ": goog.events.EventType.KEYPRESS");
        });
        
    goog.events.listen(control, goog.events.EventType.FOCUSOUT,
        function (e) {
            console.log(controlName + ": goog.events.EventType.FOCUSOUT");
        });
    
    goog.events.listen(control, goog.events.EventType.TOUCHCANCEL,
        function (e) {
            console.log(controlName + ": goog.events.EventType.TOUCHCANCEL");
        });
        
    goog.events.listen(control, goog.events.EventType.MOUSEUP,
        function (e) {
            console.log(controlName + ": goog.events.EventType.MOUSEUP");
        });
        
    goog.events.listen(control, goog.events.EventType.CHANGE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.CHANGE");
        });
        
    goog.events.listen(control, goog.events.EventType.BEFOREPASTE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.BEFOREPASTE");
        });
        
    goog.events.listen(control, goog.events.EventType.FOCUS,
        function (e) {
            console.log(controlName + ": goog.events.EventType.FOCUS");
        });
        
    goog.events.listen(control, goog.events.EventType.POPSTATE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.POPSTATE");
        });
        
        
    goog.events.listen(control, goog.events.EventType.DRAGSTART,
        function (e) {
            console.log(controlName + ": goog.events.EventType.DRAGSTART");
        });
        
    goog.events.listen(control, goog.events.EventType.CONNECT,
        function (e) {
            console.log(controlName + ": goog.events.EventType.CONNECT");
        });
        
    goog.events.listen(control, goog.events.EventType.DRAGENTER,
        function (e) {
            console.log(controlName + ": goog.events.EventType.DRAGENTER");
        });
        
    goog.events.listen(control, goog.events.EventType.MESSAGE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.MESSAGE");
        });
        
    goog.events.listen(control, goog.events.EventType.CONTEXTMENU,
        function (e) {
            console.log(controlName + ": goog.events.EventType.CONTEXTMENU");
        });
        
    goog.events.listen(control, goog.events.EventType.HASHCHANGE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.HASHCHANGE");
        });
        
    goog.events.listen(control, goog.events.EventType.DRAGLEAVE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.DRAGLEAVE");
        });
        
    goog.events.listen(control, goog.events.EventType.COPY,
        function (e) {
            console.log(controlName + ": goog.events.EventType.COPY");
        });
        
    goog.events.listen(control, goog.events.EventType.BEFORECOPY,
        function (e) {
            console.log(controlName + ": goog.events.EventType.BEFORECOPY");
        });
        
    goog.events.listen(control, goog.events.EventType.PAGEHIDE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.PAGEHIDE");
        });
        
    goog.events.listen(control, goog.events.EventType.KEYUP,
        function (e) {
            console.log(controlName + ": goog.events.EventType.KEYUP");
        });
        
    goog.events.listen(control, goog.events.EventType.UNLOAD,
        function (e) {
            console.log(controlName + ": goog.events.EventType.UNLOAD");
        });
    
//    goog.events.listen(control, goog.events.EventType.OFFLINE,
//        function (e) {
//            console.log(controlName + ": goog.events.EventType.OFFLINE");
//        });
        
//    goog.events.listen(control, goog.events.EventType.DRAG,
//        function (e) {
//            console.log(controlName + ": goog.events.EventType.DRAG");
//        });
        
    goog.events.listen(control, goog.events.EventType.CUT,
        function (e) {
            console.log(controlName + ": goog.events.EventType.CUT");
        });
        
    goog.events.listen(control, goog.events.EventType.MOUSEMOVE,
        function (e) {
            console.log(controlName + ": goog.events.EventType.MOUSEMOVE");
        });
    
    goog.events.listen(control, goog.events.EventType.CLICK,
        function (e) {
            console.log(controlName + ": goog.events.EventType.CLICK");
        });
        
    goog.events.listen(control, goog.events.EventType.MOUSEOVER,
        function (e) {
            console.log(controlName + ": goog.events.EventType.MOUSEDOWN");
        });
    
    
    //goog.ui.Component.EventType
    console.log("Appending listeners to events from goog.ui.Component.EventType");
    
    goog.events.listen(control, goog.ui.Component.EventType.UNCHECK,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.UNCHECK");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.ENABLE,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.ENABLE");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.BLUR,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.BLUR");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.FOCUS,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.FOCUS");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.CLOSE,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.CLOSE");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.DEACTIVATE,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.DEACTIVATE");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.ENTER,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.ENTER");
        });
    
    goog.events.listen(control, goog.ui.Component.EventType.LEAVE,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.LEAVE");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.BEFORE_SHOW,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.BEFORE_SHOW");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.CHECK,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.CHECK");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.ACTIVATE,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.ACTIVATE");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.SHOW,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.SHOW");
        });

    goog.events.listen(control, goog.ui.Component.EventType.HIDE,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.HIDE");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.HIGHLIGHT,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.HIGHLIGHT");
        });

    goog.events.listen(control, goog.ui.Component.EventType.SELECT,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.SELECT");
        });

    goog.events.listen(control, goog.ui.Component.EventType.UNHIGHLIGHT,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.UNHIGHLIGHT");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.OPEN,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.OPEN");
        });

    goog.events.listen(control, goog.ui.Component.EventType.DISABLE,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.DISABLE");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.ACTION,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.ACTION");
        });
        
    goog.events.listen(control, goog.ui.Component.EventType.UNSELECT,
        function (e) {
            console.log(controlName + ": goog.ui.Component.EventType.UNSELECT");
        });
}

kramerius.audio.debug_utils.getTestPlaylist = new function(){
    //TODO: opravit playList, vracet neco tady
    //return new kramerius.audio.Playlist(tracks);
    
}
